# _*_ encoding:utf-8 _*_
from django.contrib.auth.models import Group

from rest_framework.response import Response
from rest_framework.permissions import IsAdminUser
from rest_framework.viewsets import ModelViewSet

from meiduo_admin.serializers.admin_serializers import AdminModelSerializer
from meiduo_admin.serializers.group_serializers import GroupSimpleModelSerializer
from meiduo_admin.paginations import MyPage
from users.models import User


class AdminViewSet(ModelViewSet):
    permission_classes = [IsAdminUser]

    queryset = User.objects.filter(is_staff=True)
    serializer_class = AdminModelSerializer
    pagination_class = MyPage

    def get_simple_group(self, request):
        queryset = Group.objects.all()
        serializer = GroupSimpleModelSerializer(queryset, many=True)

        return Response(serializer.data)














